package com.ccb.sc.common.modules.payment.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ccb.sc.common.modules.payment.entity.Payment;
import com.ccb.sc.common.modules.payment.enums.PaymentStatus;
import com.ccb.sc.common.modules.payment.mapper.PaymentMapper;
import org.springframework.stereotype.Service;

/**
 * @author ken
 * @version 1.0
 * @date 2025/2/23 21:19
 */
@Service
public class PaymentService extends ServiceImpl<PaymentMapper, Payment> {

    public Payment getByOrderId(String orderId) {
        return this.getOne(new QueryWrapper<Payment>().lambda()
                .eq(Payment::getOrderId, orderId)
                .eq(Payment::getStatus, PaymentStatus.SUCCESS)
                .orderByDesc(Payment::getCreateTime)
                .last("limit 1"));
    }

}
